package com.wskj.insuranceweb.reporter.service;

import com.wskj.insuranceweb.reporter.mapper.ReporterMapper;
import com.wskj.insuranceweb.reporter.pojo.Backuparea;
import com.wskj.insuranceweb.reporter.pojo.Document;
import com.wskj.insuranceweb.reporter.pojo.Reporter;
import com.wskj.insuranceweb.util.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ReporterServiceImpl implements ReporterService {
    @Autowired
    private ReporterMapper mapper;


    @Override
    public PageInfo showList(String kname, String bname, Integer pageSize, Long offset) {

        Long start = (offset - 1) * pageSize;
        PageInfo page = new PageInfo();
        Long end = pageSize + start;
        page.setOffset(offset);
        page.setPageSize(pageSize);
       // page.setTotal(mapper.getCount(kname, bname));
        List<Reporter> list = mapper.showList(kname, bname, start, end);

        for (Reporter r: list
             ) {
            System.out.println(r);
        }
        page.setRows(list);
        return page;
    }

    @Override
    public void addReporter(Reporter reporter) {
        mapper.addReporter(reporter);
    }

    @Override
    public Reporter findReporter(String id) {
        return mapper.findReporter(id);
    }

    @Override
    public void addDocument(Document document) {
        mapper.addDocument(document);
    }

    @Override
    public void updateAccept(String report) {
        mapper.updateAccept(report);
    }

    @Override
    public void updateReporter(String id, String accept) {
        mapper.updateReporter(id, accept);
    }

    @Override
    public Reporter getReporter(String cust) {
        return mapper.getReporter(cust);
    }

    @Override
    public void updateReporterByCust(String cust, String rejection) {
        mapper.updateReporterByCust(cust,rejection);
    }

    @Override
    public void updateReporterNo(String id, String accept, String rejection) {
        mapper.updateReporterNo(id,accept,rejection);
    }

    @Override
    public void addBackuparea(Reporter reporter) {
        mapper.addBackuparea(reporter);
    }

    @Override
    public Reporter findReporterByReporter(String reporter) {
        return mapper.findReporterByReporter(reporter);
    }

    @Override
    public void update(Backuparea b) {
        mapper.update(b);
    }

    @Override
    public void editReporter(String report, String conclusion) {
        mapper.edtiReporter(report,conclusion);
    }
}